package com.fxkj.cloud.drms.domain.device.repository;

import com.fxkj.cloud.dbs.common.constants.DeviceStatusEnum;
import lombok.Getter;

import java.util.UUID;

/**
 * <p>description: </p>
 * @author ww
 * @date 2025/4/15 16:31
 */
@Getter
public class DeviceStatusLatestInfo {
    private UUID deviceId;
    private DeviceStatusEnum status;

    public DeviceStatusLatestInfo(UUID deviceId, DeviceStatusEnum status) {
        this.deviceId = deviceId;
        this.status = status;
    }

    public static DeviceStatusLatestInfo create(UUID deviceId, Integer status) {
        DeviceStatusEnum deviceStatusEnum = DeviceStatusEnum.of(status);
        if (null == deviceStatusEnum) {
            throw new RuntimeException("非法设备状态");
        }
        return new DeviceStatusLatestInfo(deviceId, deviceStatusEnum);
    }
}
